<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p>选择你喜欢的书：
			<input type="radio" name="book" onclick="book()" />我和狗狗一起活下来
			<input type="radio" name="book" onclick="book()" />灰霾来了怎么办
		</p>
		<div><img src="" id="image" alt="" onclick="img()" /><span></span></div>
		<script >
			function book(){
				var ele=document.getElementsByName("book");
				var img=document.getElementById("image");
				if(ele[0].checked){
					img.setAttribute("src","img/dog.jpg");
					img.setAttribute("alt","我和狗狗一起活下来");
					img.nextSibling.innerHTML="我和狗狗一起活下来";
				}else if(ele[1].checked){
					img.setAttribute("src","img/mai.jpg");
					img.setAttribute("alt","灰霾来了怎么办");
					img.nextSibling.innerHTML="灰霾来了怎么办";
				}
				
			}
			function img(){
				var alt=document.getElementById("image").getAttribute("alt");
				alert("图片的alert"+alert);
			}
		</script>
	</body>
</html>
